{extend name="public:layout" /}

{block name="title"}
	<title>{:site('siteName')}-充值审核</title>
{/block}

{block name="css"}
	<link rel="stylesheet" type="text/css" href="__STATIC__/{$theme}/css/user.css">
	<style type="text/css">
		.tips { cursor: pointer; }
	</style>
{/block}

{block name="content"}
	<div class="layui-main">
		<div class="user-main">
			<div class="user-left">
				{include file="public:user" /}
			</div>
			<div class="user-right">
				<div class="layui-tab layui-tab-brief">
					<ul class="layui-tab-title">
						<li><a href="{:url('index/agent/index')}">代理列表</a></li>
						<li class="layui-this">充值记录</li>
					</ul>
					<div class="layui-tab-content">
						<table class="table">
						    <thead>
						        <tr>
						            <th>代理信息</th>
						            <th>数量</th>
						            <th>状态</th>
						            <th>说明</th>
						            <th>时间</th>
						            <th>操作</th>
						        </tr>
						    </thead>
						    <tbody>
								{volist name="recharges" id="v"}
						        <tr>
									<td class="tips" data-msg="姓名：{$v.realname}<br>手机：{$v.mobile}<br>QQ：{$v.qq}<br>开户行：{$v.bank}<br>卡号：{$v.bank_card}">{$v.username}</td> 
									<td>{$v.num}</td>
									<td>
										{eq name="v.status" value="-1"}充值失败{/eq}
										{eq name="v.status" value="0"}待支付{/eq}
										{eq name="v.status" value="1"}已支付{/eq}
										{eq name="v.status" value="2"}充值成功{/eq}
									</td>
									<td>{$v.explain}</td>
									<td>{:date('m-d H:i',$v['create_time'])}</td>
									<td>
										{if $v['status'] == 0}
										<button data-rid="{$v.id}" class="layui-btn layui-btn-mini layui-btn-main confirm-pay">已支付</button>
										<button data-rid="{$v.id}" class="layui-btn layui-btn-mini layui-btn-danger confirm-close">取消</button>
										{/if}
									</td>
						        </tr>
								{/volist}
						    </tbody>
						</table>
						<div class="page">
							{$recharges->render()}
						</div>
					</div>
				</div> 
			</div>
		</div>
	</div>
{/block}

{block name="script"}
	<script type="text/javascript">
		layui.use(['form', 'layer'], function(){
			var $ = layui.jquery;
    		var layer = layui.layer;

    		$('.tips').mouseover(function() {
    			var tips = $(this).data('msg');
	    			layer.tips(tips, '.tips', {
				  	tips: [2, '#F7B824'],
				  	time: 5000
				});
    		});

    		$('.confirm-pay').click(function() {
    			var rid = $(this).data('rid');
    			checkPwd(function(pwd){
	    			layer.confirm('确认已经支付。', {
			            btn: ['确认', '取消'],
			            icon: 3
			        }, function(index) {
			        	$.post('{:url("index/agent/record")}', {id: rid,status:'1',pwd:pwd}, function(res) {
			            	if(res.status == 1){
			            		layer.msg(res.msg, {
				                    time: 1000
				                }, function() {
				                    location.reload();
				                });
			            	}else{
			            		layer.msg(res.msg);
			            	}
			            },'json');
			            layer.close(index);
			        });
    			});
		        return false;
    		});

    		$('.confirm-close').click(function() {
    			var rid = $(this).data('rid');
    			checkPwd(function(pwd){
    				layer.confirm('确认取消充值。', {
			            btn: ['确认', '取消'],
			            icon: 3
			        }, function(index) {
			        	$.post('{:url("index/agent/record")}', {id: rid,status:'-1',pwd:pwd}, function(res) {
			            	if(res.status == 1){
			            		layer.msg(res.msg, {
				                    time: 1000
				                }, function() {
				                    location.reload();
				                });
			            	}else{
			            		layer.msg(res.msg);
			            	}
			            },'json');
			            layer.close(index);
			        });
    			});
    			
		        return false;
    		});
    		
		});
	</script>
{/block}